package py.com.erpone.entity.dm;

import java.io.Serializable;

import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToOne;
import javax.persistence.PrimaryKeyJoinColumn;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

import py.com.erpone.entity.almacen.LoteDetalle;

@Entity
@NamedQueries(value = {@NamedQuery(name = "divisiones.all", query = "select a from SectorDivision a order by a.nombre")})
public class SectorDivision implements Serializable{
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	@Id
	@GeneratedValue(strategy=GenerationType.AUTO)
	private Long id;
	
	@NotNull
	@Size(max = 10)
	private String nombre;
	
	@NotNull
	@Size(max = 30)
	private String sectorDivisionConcat;
	
	@ManyToOne
	private Sector sector;
	
	@OneToOne(mappedBy = "sectorDivision")
	private LoteDetalle loteDetalle;
	
	
	public SectorDivision() {
		super();
		
	}


	public SectorDivision(Long id, String nombre, String sectorDivisionConcat,
			Sector sector, LoteDetalle loteDetalle) {
		super();
		this.id = id;
		this.nombre = nombre;
		this.sectorDivisionConcat = sectorDivisionConcat;
		this.sector = sector;
		this.loteDetalle = loteDetalle;
	}


	public Long getId() {
		return id;
	}


	public void setId(Long id) {
		this.id = id;
	}


	public String getNombre() {
		return nombre;
	}


	public void setNombre(String nombre) {
		this.nombre = nombre;
	}


	public String getSectorDivisionConcat() {
		return sectorDivisionConcat;
	}


	public void setSectorDivisionConcat(String sectorDivisionConcat) {
		this.sectorDivisionConcat = sectorDivisionConcat;
	}


	public Sector getSector() {
		return sector;
	}


	public void setSector(Sector sector) {
		this.sector = sector;
	}


	public LoteDetalle getLoteDetalle() {
		return loteDetalle;
	}


	public void setLoteDetalle(LoteDetalle loteDetalle) {
		this.loteDetalle = loteDetalle;
	}


	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		result = prime * result
				+ ((loteDetalle == null) ? 0 : loteDetalle.hashCode());
		result = prime * result + ((nombre == null) ? 0 : nombre.hashCode());
		result = prime * result + ((sector == null) ? 0 : sector.hashCode());
		result = prime
				* result
				+ ((sectorDivisionConcat == null) ? 0 : sectorDivisionConcat
						.hashCode());
		return result;
	}


	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		SectorDivision other = (SectorDivision) obj;
		if (id == null) {
			if (other.id != null)
				return false;
		} else if (!id.equals(other.id))
			return false;
		if (loteDetalle == null) {
			if (other.loteDetalle != null)
				return false;
		} else if (!loteDetalle.equals(other.loteDetalle))
			return false;
		if (nombre == null) {
			if (other.nombre != null)
				return false;
		} else if (!nombre.equals(other.nombre))
			return false;
		if (sector == null) {
			if (other.sector != null)
				return false;
		} else if (!sector.equals(other.sector))
			return false;
		if (sectorDivisionConcat == null) {
			if (other.sectorDivisionConcat != null)
				return false;
		} else if (!sectorDivisionConcat.equals(other.sectorDivisionConcat))
			return false;
		return true;
	}


	@Override
	public String toString() {
		return "SectorDivision [id=" + id + ", nombre=" + nombre
				+ ", sectorDivisionConcat=" + sectorDivisionConcat
				+ ", sector=" + sector + ", loteDetalle=" + loteDetalle + "]";
	}


	
	
}
